/**
* \file DGVPlotVTK.h
*
* \brief This file defines the class for X-Y Plots using VTK from Blitz++ Arrays.
* \author Shekhar S. Chandra, 2008-2009
*
* This file is part of DGV Library.
*
* DGV is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DGV is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DGV.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DGVPLOTVTK_H
#define DGVPLOTVTK_H

#include "QVTKWidget.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkXYPlotActor.h"
#include "vtkImageData.h"

#include "DGVAliases.h"

/*!
    \class DGVPlotVTK
    \brief This class represents the DGV Plot Display object using VTK. WORK IN PROGESS.
    \author Shekhar S. Chandra, 2009

    The class displays X-Y plots from values using OpenGL via the VTK library. The rendering is encapsulated within
    a QVTK widget.

    Usage Example:
    \code
    DGVPlotVTK *plot = new DGVPlotVTK(this);

    plot->setData(hist->GetOutput());
    plot->generatePlot();
    plot->show();
    \endcode
*/
class DGV_VTK_EXPORT DGVPlotVTK : public QVTKWidget
{
    Q_OBJECT

public:
    /*!
        \fn DGVPlotVTK::DGVPlotVTK(QWidget *parent = 0)
        \brief Constructor
	*/
    DGVPlotVTK(QWidget *parent = 0);
    /*!
        \fn DGVPlotVTK::~DGVPlotVTK()
        \brief Destructor
	*/
    virtual ~DGVPlotVTK();

    /*!
        \fn DGVPlotVTK::setName(QString filename)
        \brief Gives the plot a new name.
	*/
	void setName(QString filename);
    /*!
        \fn DGVPlotVTK::setData(vtkImageData *data)
        \brief Adds the data to the plot ready to be generated. Call this before generatePlot().
	*/
    void setData(vtkImageData *data);
    /*!
        \fn DGVPlotVTK::setRanges(double xmin, double xmax, double ymin, double ymax)
        \brief Sets the range of the plot of the data. If ranges for each dimension is the same, it will be computed automatically.
	*/
    void setRanges(double xmin, double xmax, double ymin, double ymax);
    /*!
        \fn DGVPlotVTK::generatePlot()
        \brief Generates the actual plot so it can be displayed. Call this after data and its ranges have been set.
	*/
    void generatePlot();

    /*!
        \fn DGVPlotVTK::strippedName()
        \brief Returns the stripped (path removed) name of the image.
	*/
	QString strippedName();
	/*!
        \fn DGVPlotVTK::strippedNamePrefix()
        \brief Returns the stripped (path removed) name of the image with "Plot" prefix.
	*/
	QString strippedNamePrefix();

protected:
    QString name; //!< Name of the Image
    bool loaded; //!< Is the data loaded?

    vtkXYPlotActor *plotActor; //!< Plot handler

    vtkRenderer *renderer; //!< Renderer of the plot
    vtkRenderWindow *renderWin; //!< Window that controls the renderer
};

#endif // DGVPLOTVTK_H
